package model

type User struct {
	UserId     uint32 `api:"rand" xorm:"pk"`
	UserName   string
	Email      string
	Phone      string
	Password   string `api:"hidden"`
	UserType   string
	Status     string
	Desc       string
	CreateTime uint32 `api:"createtime"`
}

type DeviceGroup struct {
	DeviceGroupId   uint32 `api:"rand" xorm:"pk"`
	DeviceGroupName string
	Desc            string
	DeviceCount     uint32
	ShowIndex       uint32 `api:"createtime"`
	CreateTime      uint32 `api:"createtime"`
}

type Device struct {
	DeviceId      uint32 `api:"rand" xorm:"pk"`
	DeviceGroupId uint32

	Name          string
	Code          string
	Desc          string
	Otg           string
	Ip            string
	Port          string
	Status        string
	LatestConnect uint32 `api:"createtime"`

	ShowIndex  uint32 `api:"createtime"`
	CreateTime uint32 `api:"createtime"`
}

type DeviceWithGroup struct {
	Device          `xorm:"extends"`
	DeviceGroupName string
}

func (DeviceWithGroup) TableName() string {
	return "device"
}

type Task struct {
	TaskId uint32 `api:"rand" xorm:"pk"`

	Retry           int
	HoldSec         int
	ProductPath     string
	DeviceGroupId   uint32
	DeviceGroupName string

	Name   string
	Desc   string
	Status string

	AppointmentTime int64 // 预约时间
	StopTime        int64 // 超时结束时间
	StartTime       int64 // 实际执行时间
	DoneTime        int64 // 完成时间
	ProductCount    int
	DeviceCount     int

	CreateTime uint32 `api:"createtime"`
}

// 商品执行日志
// 包含商品, 执行设备信息
type LogProduct struct {
	ProductId       uint64 `api:"rand" xorm:"pk"`
	TaskId          uint32 // 对应任务id
	DeviceGroupId   uint32 // 执行分组
	DeviceGroupName string // 执行分组名称

	Account      string // 逛号
	ProductCode  string
	ProductTitle string
	ReleaseTime  string
	Addr         string
	HoldSec      int

	Status      string
	DeviceCount int
	DeviceDone  int

	CreateTime uint32 `api:"createtime"`
}

type LogProductDevice struct {
	LogId uint64 `api:"rand" xorm:"pk"`

	TaskId    uint32
	ProductId uint64

	DeviceId uint32
	Name     string
	Code     string

	SendCount int
	StartTime int64
	EndTime   int64
	IsSuccess string // Y/N
	ImgUrl    string

	CreateTime uint32 `api:"createtime"`
}

// type ProductWithGroup struct {
// 	Product         `xorm:"extends"`
// 	DeviceGroupName string
// }

// func (ProductWithGroup) TableName() string {
// 	return "product"
// }
